class_name BulletData
extends EntityData

@export_group("通用属性")
@export var speed:float = 100:
	get:return speed
	set(value):
		speed = value
		data_changed.emit("Speed")
@export var default_camp:GameEnum.Camp = GameEnum.Camp.None:
	get:return default_camp
	set(value):
		default_camp = value
		data_changed.emit("Camp")
@export_group("")
@export_group("LayerMask")
@export_flags_2d_physics var layer_mask_friendly = (1<<0)
@export_flags_2d_physics var layer_mask_hostile = (1<<1)
@export_flags_2d_physics var layer_mask_neutral = (1<<2)
@export_flags_2d_physics var layer_mask_obstacle = (1<<4) | (1<<6) | (1<<7) | (1<<8) | (1<<9)
@export_flags_2d_physics var layer_mask_sky_obstacle = (1<<7)
@export_group("")
@export_group("特殊属性")

@export_group("")
@export_group("运行时属性")
var source_entity:
	get:return source_entity
	set(value):
		source_entity = value
@export_group("")
func get_layer_mask_by_tag(tag:String) -> int:
	match tag:
		"None":return 0
		"Friendly":return layer_mask_friendly
		"Hostile":return layer_mask_hostile
		"Neutral":return layer_mask_neutral
		"Obstacle":return layer_mask_obstacle
		"Sky_Obstacle":return layer_mask_sky_obstacle
		_:return 0

func get_temp_data(source_entity:Node, source:Node,value:float):
	if source_entity and "get_entity_data" in source_entity:
		var data = source_entity.get_entity_data()
		if value < 0 and "get_damage_multiplier" in data:
			# TODO 是否暴击先暂定为false，现在还没决定怎么确认一定暴击
			value = value * data.get_damage_multiplier(false)
		elif  value > 0 and "get_recover_scale" in data:
			value = value * data.get_recover_scale()
	value = abs(value)
	var temp_data = TempEntityData.new(source_entity,source, value)
	return temp_data

#新增组别实例
#@export_subgroup("分组名 tag")
#@export var xxx:int = 0:
	#get:return xxx
	#set(value):
		#xxx = value
		#data_changed.emit("Tag")
